package com.war.controller.stock;

import com.war.dao.stock.DamagesDao;
import com.war.dao.stock.TransferDao;
import com.war.pojo.stock.DamagesInfo;
import com.war.pojo.stock.TransferInfo;
import com.war.service.safeManage.UserService;
import com.war.service.stock.TransferInfoService;
import com.war.service.system.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("/transfer")
public class TransferController {
    @Autowired(required = false)
    TransferInfoService transferInfoService;
    WarehouseService warehouseService;

    @RequestMapping("")
    public String list(TransferInfo transferInfo,ModelMap m){
        HashMap<String,Object> map = transferInfoService.index(transferInfo);
        //把数据传到前端
        m.put("info",map);
        return "stock/transfer/transfer-list";
    }

    //仓库
    @RequestMapping("/add")
    public String add(){
        return "stock/transfer/transfer-add";
    }

    @RequestMapping("/addAjax")
    @ResponseBody
    public HashMap<String,Object> addAjax(TransferInfo transferInfo){
        HashMap<String,Object> map = transferInfoService.add(transferInfo);
        return map;
    }

    @RequestMapping("/edit")
    public String edit(TransferInfo transferInfo,ModelMap m){
        HashMap<String,Object> map = transferInfoService.selectById(transferInfo);
        //把数据传到前端
        m.put("info",map);
        return "stock/transfer/transfer-edit";
    }

    @RequestMapping("/editAjax")
    @ResponseBody
    public HashMap<String,Object> editAjax(TransferInfo transferInfo){
        HashMap<String,Object> map = transferInfoService.updateById(transferInfo);
        return map;
    }

    @RequestMapping("/deleteAjax")
    @ResponseBody
    public HashMap<String,Object> deleteAjax(TransferInfo transferInfo){
        HashMap<String,Object> map = transferInfoService.deleteById(transferInfo);
        return map;
    }

    @RequestMapping("/select")
    @ResponseBody
    public HashMap<String,Object> select(TransferInfo transferInfo){
        HashMap<String,Object> map = transferInfoService.selectAll(transferInfo);
        //把数据传到前端
        return map;
    }
}
